<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #res{
            color: #d35400;
            font-weight: bold;
            font-size: 30px;
            background-color:#2ecc71;
            width: 200px;
            height: 40px;
            border-radius: 50px;
            text-align: center;
        }
    </style>
</head>
<body>
<form action="" method="post">
    <table border="1" style="border-collapse:collapse;">
    <tr>
        <td colspan="2">你认为Bob喜欢的字母代表的意思是什么吗?</td>
    </tr>
    <tr>
        <td>
            <select name="find" id="">
                <option value="a">LIKE A</option>
                <option value="b">LIKE B</option>
                <option value="c">LIKE C</option>
                <option value="d">LIKE D</option>
            </select>
        </td>
        <td><input type="submit" name="sb">SUBMIT</td>
    </tr>
    </table>
    <p id="res"></p>
</form>
</body>
</html>


<?php
    session_start();
    if(isset($_POST['sb'])){
        $find = $_POST['find'];
        $res = '';
        // if($find == 'a')
        //     $res =  '我喜欢A';
        // elseif($find == 'b')
        //     $res =  '我喜欢B';
        // elseif($find == 'c')
        //     $res =  '我喜欢C';
        // elseif($find == 'd')
        //     $res =  '我喜欢D';
        // else
        //     $res =  '我什么都不喜欢';


        switch($find){
            case 'a':
                $res = '我喜欢A';
                break;
            case 'b':
                $res = '我喜欢B';
                break;
            case 'c':
                $res = '我喜欢C';
                break;
            case 'd':
                $res = '我喜欢D';
                break;
            default:
                $res = '我什么都不喜欢';
                break;
        }
        $_SESSION['res'] = $res;
        $show_res = $_SESSION['res'];
    }
?>


<script type="text/javascript">
    //在js中也可以读取php变量的值，因为这里面使用的是php环境  所以可以读取到
    let show_res = "<?php echo $show_res;?>";
    let res = document.getElementById('res');
    res.innerHTML = show_res;
</script>